package com.example.demo.pdfbox.tabel;

import com.example.demo.pdfbox.common.PdfDocument;
import com.example.demo.pdfbox.common.PdfMargin;
import com.example.demo.pdfbox.common.function.PdfContent;
import lombok.Getter;
import org.apache.pdfbox.pdmodel.common.PDRectangle;

import java.util.ArrayList;
import java.util.List;

public class PdfTable extends PdfDocument implements PdfContent {

    @Getter
    private List<PdfPage> pageList = new ArrayList<>();

    public void addPage(PdfPage page) {
        pageList.add(page);
    }

    @Override
    public PDRectangle getCurrentPageRectangle() {
        if (!pageList.isEmpty()) {
            return pageList.get(pageList.size() - 1).rectangle;
        }
        return null;
    }

    @Override
    public PdfMargin getCurrentPageMargin() {
        if (!pageList.isEmpty()) {
            return pageList.get(pageList.size() - 1).margin;
        }
        return null;
    }
}
